{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 504x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAcEAAAEeCAYAAADy064SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZhU5Zn38e9Ns7QKcWFRBEwj8hI0CGrHDWMQo0GHQBgjYhwlGQ0mo+OW10RGY9REkkxcJipRO2rUDAGJKzFKVIRXBTFBAw5KGBARWxA6uIBG9vv945xqq6F6Kag69VSf3+e66uqqc05V/bq6uu4653nO85i7IyIikkZtSh1ARESkVFQERUQktVQERUQktVQERUQktVQERUQktdqWOkAhdenSxauqqkodQ0REAvLyyy//3d275lrXqopgVVUV8+bNK3UMEREJiJm91dg6HQ4VEZHUUhEUEZHUUhEUEZHUalVtgrls3ryZ2tpaNmzYUOoorV5lZSU9e/akXbt2pY4iItIirb4I1tbW0qlTJ6qqqjCzUsdptdydtWvXUltbS+/evUsdR0SkRVr94dANGzbQuXNnFcAiMzM6d+6sPW4RKSutvggCKoAJ0essIuUmFUVQREQkl9QVQbPCXlqioqKCQYMG8fnPf56vfvWrfPDBBw3WDxs2jHfeeQeAuro62rVrx5133tlgm6qqKgYMGMCgQYMYNGgQF110Uf26LVu20KVLF8aPH9/gPkOGDKFfv34MHDiQwYMHs3jx4p14xUREWq9W3zEmBLvtthvz588HYOzYsUycOJErr7wSgE8++YT33nuPHj16APD73/+eo48+msmTJ3P++ec3eJyZM2fSpUuXHR7/qaeeol+/fkydOpUJEyY0OCw5adIkqqurqamp4fLLL2fatGnF+jVFpBE1NTU7LBs3blwJksj2UrcnWGrHHHNM/V4fwKxZsxg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UnJm1sXd/x5AjgFEhfkgoi9Wte7+fim+uGyXq2SFb3sWdfc/kagAXhe3LwsNPhe3uftGM2sP/DMwnuh9NQWYQXQ0poe7X1WUHCqC6WNmHYk7Rbn7uhLHyanUH6TlIKQPe2mZ0N7XIeUxs/8kapt8BLjc3Zdl8sXNOC+4e8E7yKlNMJ0+DuWN35jQ84VABbB8ZD7MQ3tflzpPVpH7D6JmhxHuXt9ZKKvn6peAB4uRQUUwhUr9xhdJG/3P5RYXuUpgP+CC7Hb3uHnkMOBcov4LS4qRQUVQRERKqS9RT/nsAngAcDxwIdH5lRcX68lVBEVEpGTi0zfWxKcAVQL9ic73PBl4mmig9lXFen51jBERkZIys17APxENnLGYqBjekekIU8xOYCqCIiISjOzRYjLDphWzTVVFUEREgpPU6RsqgiIiklqaRUJERFJLRVBERFJLRVBERFJLRVBERFJLRVBERFJLRVBERFJLRVBERFLr/wOicTN/vGz6oQAAAABJRU5ErkJggg==\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import csv\n",
    "%matplotlib inline\n",
    "import numpy as np\n",
    "import os\n",
    "import re\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.ticker as ticker\n",
    "\n",
    "DIR_NAME = './solutions/'\n",
    "FIG_SIZE = (7, 4    )  # height * width\n",
    "BAR_WIDTH = 0.15  # width of bar\n",
    "fontdict = {'family': 'Times New Roman', 'weight': 'normal', 'size':15}\n",
    "colors = {\n",
    "    'R/AEAP': 'blue', 'R/AEAP-BF': 'green', 'R/AEAP-WF': '#e68a00',\n",
    "    'D/AEAP': '#80aaff', 'd-aeapbf': 'green', 'd-aeapwf': 'red',\n",
    "    'ILS': '#999999',\n",
    "}\n",
    "\n",
    "filenames = os.listdir(DIR_NAME)\n",
    "filenames_dict = {\n",
    "    'R/AEAP': [],\n",
    "    'R/AEAP-BF': [],\n",
    "    'R/AEAP-WF': [],\n",
    "    'D/AEAP': [],\n",
    "    # 'd-aeapbf': [],\n",
    "    # 'd-aeapwf': [],\n",
    "    'ILS': []\n",
    "}\n",
    "\n",
    "for filename in filenames:\n",
    "    if re.match(r'b.*backtracking.*aeap\\.csv', filename):\n",
    "        filenames_dict['R/AEAP'].append(filename)\n",
    "    elif re.match(r'b.*backtracking.*aeapbf\\.csv', filename):\n",
    "        filenames_dict['R/AEAP-BF'].append(filename)\n",
    "    elif re.match(r'b.*backtracking.*aeapwf\\.csv', filename):\n",
    "        filenames_dict['R/AEAP-WF'].append(filename)\n",
    "    elif re.match(r'b.*dijkstra.*aeap\\.csv', filename):\n",
    "        filenames_dict['D/AEAP'].append(filename)\n",
    "    # elif re.match(r'b.*t1.*dijkstra.*aeapbf\\.csv', filename):\n",
    "    #     filenames_dict['d-aeapbf'].append(filename)\n",
    "    # elif re.match(r'b.*t1.*dijkstra.*aeapwf\\.csv', filename):\n",
    "    #     filenames_dict['d-aeapwf'].append(filename)\n",
    "    elif re.match(r'o.*backtracking.*aeap\\.csv', filename):  # only care about R/AEAP\n",
    "        filenames_dict['ILS'].append(filename)\n",
    "\n",
    "fig, ax = plt.subplots(figsize=FIG_SIZE)\n",
    "ax.set_title('')\n",
    "labels = ['flow-{}'.format(i) for i in range(1, 20)]  # flows no.\n",
    "x = np.arange(len(labels))\n",
    "\n",
    "i = 0\n",
    "for alias, filenames in filenames_dict.items():\n",
    "    filename = filenames[0]  # take first file\n",
    "    y = []\n",
    "    with open(os.path.join(DIR_NAME, filename), 'r') as file:\n",
    "        reader = csv.reader(file)\n",
    "        for line in reader:\n",
    "            y.append(int(line[1]) / 1000)  # reliability\n",
    "    x = x[:10]\n",
    "    y = y[:10]\n",
    "    if i < 2:\n",
    "        ax.bar(x - BAR_WIDTH * (2 - i), y, width=BAR_WIDTH, label=alias, color=colors[alias])\n",
    "    elif i == 2:\n",
    "        ax.bar(x, y, width=BAR_WIDTH, label=alias, color=colors[alias])\n",
    "    else:\n",
    "        ax.bar(x + BAR_WIDTH * (i - 2), y, width=BAR_WIDTH, label=alias, color=colors[alias])\n",
    "    i += 1\n",
    "plt.xticks(rotation=-60)\n",
    "ax.set_xticks(x)\n",
    "labels = labels[:10]\n",
    "ax.set_xticklabels(labels, fontdict=fontdict)\n",
    "ax.set_ylabel('Delay (in μs)', fontdict=fontdict)\n",
    "ax.legend()\n",
    "fig.savefig('./fig_delay.png', dpi=300, bbox_inches = \"tight\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}